package java06;
import java.util.ArrayList;
import java.util.Collections;
public class CollectionsTest01 {
    public static void main(String[] args){
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"C","Z","B","K");//添加元素
        System.out.println("排序前：" + list);
        Collections.reverse(list);//反转集合
        System.out.println("反转后：" + list);
        Collections.sort(list);//按自然顺序排序
        System.out.println("按自然顺序排序后：" + list);
        Collections.shuffle(list);//随机打乱集合元素
        System.out.println("按随机顺序排序后:" + list);
        Collections.swap(list,1,list.size()-1);//交换指定下标的两个元素
        System.out.println("交换集合指定下标的两个元素后:" + list);
    }
}
